home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRLEN.C < prev    next >
Text File  |  1993-01-04  |  896b  |  39 lines

  1.  
  2. /*  File   : strlen.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 23 April 1984
  5.     Defines: strlen()
  6.  
  7.     strlen(s) returns the number of characters in s, that is, the number
  8.     of non-NUL characters found before the closing NULEosCh.  Note: some
  9.     non-standard C compilers for 32-bit machines take int to be 16 bits,
  10.     either put up with short strings or change int  to  long  throughout
  11.     this package.  Better yet, BOYCOTT such shoddy compilers.
  12.     Beware: the asm version works only if strlen(s) < 65536.
  13. */
  14.  
  15. #include "strings.h"
  16.  
  17. #if     VaxAsm
  18.  
  19. int strlen(s)
  20.     char *s;
  21.     {
  22.         asm("locc  $0,$65535,*4(ap)");
  23.         asm("subl3 r0,$65535,r0");
  24.     }
  25.  
  26. #else  ~VaxAsm
  27.  
  28. int strlen(s)
  29.     register char *s;
  30.     {
  31.         register int L;
  32.  
  33.         for (L = 0; *s++; L++) ;
  34.         return L;
  35.     }
  36.  
  37. #endif  VaxAsm
  38.  
  39.